package org.example.util6;

public class Employee implements Comparable<Employee>{
    private String name;
    private Double salary;
    public Employee(String name, Double salary) {
        this.name = name;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }


    public Double getSalary() {
        return salary;
    }

    public void raiseSalary(Double byPercent) {
        double raise = salary * byPercent / 100;
        salary += raise;
    }
    @Override
    public int compareTo(Employee o) {
        //使用 Arrays 类的 sort 方法对 Employee 对象数组进行排序， Employee类就必须实现Compareable接口
        return Double.compare(salary, o.getSalary());
    }
}
